import { mapGetters } from 'vuex'

export default {
	computed: {
		...mapGetters('m_cart', ['total'])
	},
	// 页面显示
	onShow() {
		if (this.total) {
			uni.setTabBarBadge({index: 2, text: String(this.total)})
		}
	},
	watch: {
		total(n) {
			n ? uni.setTabBarBadge({ index: 2, text: String(n)}) : uni.removeTabBarBadge({ index: 2 })
		}
	}
}